﻿package com.wandian.view.mediator
{
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.model.InRoomPlayerDataProxy;
	import com.wandian.model.vo.PlayerVo;
	import com.wandian.model.vo.PropVo;
	import com.wandian.view.components.ui.CardTypeTipPanel;
	import com.wandian.view.components.ui.SitPlayerPanel;
	import com.wandian.view.components.ui.SystemTip;

	import flash.display.Sprite;
	import flash.geom.Point;

	import org.puremvc.as3.interfaces.*;
	import org.puremvc.as3.patterns.mediator.*;
	/**   
	* @author long
	* @QQ 108232706
	* @version 1.0   
	*/   
	public class TipMediator extends Mediator
	{
		private var _global:GameData;
		private var _mcFullTip:Sprite;
		private var _playerPanelMc:Sprite;
		private var playerPanel:SitPlayerPanel;
		private var _inRoomData:InRoomPlayerDataProxy;
		private var _systemTip:SystemTip;
		private var _cardRankTip:CardTypeTipPanel;
		private var _arrMask:Array;
		public static const NAME:String="TipMediator";

		public function TipMediator(viewComponent:Object=null)
		{
			this._global=GameData.getInstance();
			this._systemTip=new SystemTip();
			this._arrMask=[];
			super(NAME, viewComponent);
			return;
		} 

		override public function onRegister():void
		{
            this._inRoomData = facade.retrieveProxy(InRoomPlayerDataProxy.NAME) as InRoomPlayerDataProxy;
			return;
		} 

		override public function listNotificationInterests():Array
		{
			return [CLZNoticeName.SHOW_WINDOWS_TIP,CLZNoticeName.TIPMEDIATOR_SHOW_MOVE_TIP,CLZNoticeName.SHOW_MOVE_TIP, CLZNoticeName.TIPMEDIATOR_SHOW_FULL_TIP, CLZNoticeName.TIPMEDIATOR_HIDE_FULL_TIP, CLZNoticeName.TIPMEDIATOR_SHOW_WINDOWS_TIP, CLZNoticeName.TIPMEDIATOR_HIDE_WINDOWS_TIP, CLZNoticeName.OUT_PLAYER, CLZNoticeName.OVER_PLAYER, CLZNoticeName.BTN_PLAYER_OPERATE, CLZNoticeName.CLOSE_BTN_PLAYER_OPERATE, CLZNoticeName.STAND_UP_RSP, CLZNoticeName.SHOW_USE_SELECTED_TIP, CLZNoticeName.HIDE_USE_SELECTED_TIP, CLZNoticeName.USE_PROP_TYPE, CLZNoticeName.BUYIN_PROP_TIP_WINDOW, CLZNoticeName.SEND_PROP_TIP_WINDOW, CLZNoticeName.CLOSE_PROP_TIP_WINDOW, CLZNoticeName.HIDE_SHOPING, CLZNoticeName.OK_GIVE_BUY_PROP_GIFT, CLZNoticeName.HIDE_WINDOWS_TIP, CLZNoticeName.SHOW_FULL_TIP, CLZNoticeName.SHOW_HONOR_TIP, CLZNoticeName.HIDE_HONOR_TIP, CLZNoticeName.INIT_CARD_RANK_TIP, CLZNoticeName.SHOW_CARD_RANK_TIP, CLZNoticeName.HIDE_CARD_RANK_TIP];
		} 

		override public function handleNotification(notification:INotification):void
		{
			var body:Object=notification.getBody();
			var mc:Sprite;
			var playerVo:PlayerVo;
			var point:Point;
			switch (notification.getName())
			{
				case CLZNoticeName.TIPMEDIATOR_SHOW_MOVE_TIP:
				{
					this._systemTip.showMoveTip(notification.getBody());
					break;
				}
				case CLZNoticeName.TIPMEDIATOR_SHOW_WINDOWS_TIP:
				{
					this._systemTip.setMcWindowsTip(GameData.getSprite("SystemWindowTip"), body.isSendClose, body.okNoticeName, body.tip, body.tipTitle, body.data, body.isCancel, body.okTip, body.cancelTip, int(body.countTime));
					break;
				}
				case CLZNoticeName.TIPMEDIATOR_HIDE_WINDOWS_TIP:
				{
					this._systemTip.removeMcWindowsTip();
					break;
				}
				case CLZNoticeName.SHOW_FULL_TIP:
				{
					this._systemTip.showFullTip(body.tip, body.isShowBtn, body.btnName, body.strNoticeName);
					break;
				}
				case CLZNoticeName.HIDE_FULL_TIP:
				{
					this._systemTip.removeShowFullTip();
					break;
				}
				case CLZNoticeName.SHOW_WINDOWS_TIP:
				{
					mc=GameData.getSprite("SystemWindowTip");
					this._systemTip.setMcWindowsTip(mc, body.isSendClose, body.okNoticeName, body.tip, body.tipTitle, body.data, body.isCancel, body.okTip, body.cancelTip, int(body.countTime));
					break;
				}
				case CLZNoticeName.HIDE_WINDOWS_TIP:
				{
					this._systemTip.removeMcWindowsTip();
					break;
				}
				case CLZNoticeName.SHOW_MOVE_TIP:
				{
					this._systemTip.showMoveTip(body);
					break;
				}
				case CLZNoticeName.HIDE_MOVE_TIP:
				{
					break;
				}
				case CLZNoticeName.OVER_PLAYER:
				{
					playerVo=this._inRoomData.getSitPlayerBySeatId(notification.getBody() as int) as PlayerVo;
					if (playerVo.userid == 0)
					{
						return;
					}
					this._systemTip.showOverPlayerTip(playerVo);
					break;
				}
				case CLZNoticeName.OUT_PLAYER:
				{
					this._systemTip.hideOutPlayerTip();
					break;
				}
				case CLZNoticeName.BTN_PLAYER_OPERATE:
				{
					body=notification.getBody();
					playerVo=this._inRoomData.getSitPlayerBySeatId(body.seatId) as PlayerVo;
					if (this._playerPanelMc == null||this.playerPanel==null)
					{
						this._playerPanelMc=GameData.getSprite("SitPlayerPanel");
						this.playerPanel=new SitPlayerPanel(this._playerPanelMc);
					}
					this.playerPanel.player=playerVo;
					Texas.I._mcTipView.addChild(this._playerPanelMc);
					point=body.point;
					this._playerPanelMc.x=point.x;
					this._playerPanelMc.y=point.y;
					break;
				}
				case CLZNoticeName.CLOSE_BTN_PLAYER_OPERATE:
				{
					if (this._playerPanelMc != null)
					{
					}
					if (Texas.I._mcTipView.contains(this._playerPanelMc))
					{
						Texas.I._mcTipView.removeChild(this._playerPanelMc);
					}
					break;
				}
				case CLZNoticeName.STAND_UP_RSP:
				{
					if (this.playerPanel != null)
					{
						if (body.seatId == this.playerPanel.player.seatId)
						{
							this.sendNotification(CLZNoticeName.CLOSE_BTN_PLAYER_OPERATE);
						}
					}
				
					break;
				}
				case CLZNoticeName.SHOW_USE_SELECTED_TIP:
				{
					this._systemTip.showUseTip(body);
					break;
				}
				case CLZNoticeName.HIDE_USE_SELECTED_TIP:
				{
					this._systemTip.removeUseTip();
					break;
				}
				case CLZNoticeName.USE_PROP_TYPE:
				{
					this.sendNotification(CLZNoticeName.USE_PROP_REQ, body);
					break;
				}
				case CLZNoticeName.BUYIN_PROP_TIP_WINDOW:
				{
					this._systemTip.showPropTipPanel(CLZNoticeName.BUYIN_PROP_TIP_WINDOW, body as PropVo);
					break;
				}
				case CLZNoticeName.SEND_PROP_TIP_WINDOW:
				{
					this._systemTip.showPropTipPanel(CLZNoticeName.SEND_PROP_TIP_WINDOW, body as PropVo);
					break;
				}
				case CLZNoticeName.CLOSE_PROP_TIP_WINDOW:
				{
					this._systemTip.removePropTip();
					break;
				}
				case CLZNoticeName.HIDE_SHOPING:
				{
					this.sendNotification(CLZNoticeName.CLOSE_PROP_TIP_WINDOW);
					break;
				}
				case CLZNoticeName.OK_GIVE_BUY_PROP_GIFT:
				{
					if (body.arrMid.length != 1)
					{
						return;
					}
					this.sendNotification(CLZNoticeName.GIVE_GIFT_REQ, body);
					break;
				}
				case CLZNoticeName.SHOW_FULL_TIP:
				{
					this._systemTip.showFullTip(body.tip, body.isShowBtn, body.btnName, body.strNoticeName);
					break;
				}
				case CLZNoticeName.HIDE_FULL_TIP:
				{
					this._systemTip.removeShowFullTip();
					break;
				}
				case CLZNoticeName.SHOW_HONOR_TIP:
				{
					GameData.arrHonorTip.push(body);
					this._systemTip.showHonorTip();
					break;
				}
				case CLZNoticeName.HIDE_HONOR_TIP:
				{
					this._systemTip.hideHonorTip();
					break;
				}
				case CLZNoticeName.INIT_CARD_RANK_TIP:
				{
					if (this._cardRankTip != null)
					{
						return;
					}
					this._cardRankTip=new CardTypeTipPanel(GameData.getSprite("CardTypeTipPanel"));
					break;
				}
				case CLZNoticeName.SHOW_CARD_RANK_TIP:
				{
					this._cardRankTip.show();
					break;
				}
				case CLZNoticeName.HIDE_CARD_RANK_TIP:
				{
					this._cardRankTip.hide();
					break;
				}
				default:
				{
					break;
				}
			}
		}

		/*public function handleNotification1(notification:INotification):void
		{
			var body:Object=null;
			var curPlayerVo:PlayerVo=null;
			var mc:Sprite=null;
			var _loc_5:uint=0;
			var showPoint:Point=null;
			body=notification.getBody();
			switch (notification.getName())
			{
				case CLZNoticeName.SHOW_WINDOWS_TIP:
				{
					mc=GameData.getSprite("SystemWindowTip");
					_loc_5=int(body.countTime);
					this._systemTip.setMcWindowsTip(mc, body.isSendClose, body.okNoticeName, body.tip, body.tipTitle, body.data, body.isCancel, body.okTip, body.cancelTip, _loc_5);
					break;
				}
				case CLZNoticeName.HIDE_WINDOWS_TIP:
				{
					this._systemTip.removeMcWindowsTip();
					break;
				}
				case CLZNoticeName.SHOW_MOVE_TIP:
				{
					this._systemTip.showMoveTip(body);
					break;
				}
				case CLZNoticeName.HIDE_MOVE_TIP:
				{
					break;
				}
				case CLZNoticeName.OVER_PLAYER:
				{
					curPlayerVo=this._inRoomData.getSitPlayerBySeatId(notification.getBody() as int) as PlayerVo;
					if (curPlayerVo.userid == 0)
					{
						return;
					}
					this._systemTip.showOverPlayerTip(curPlayerVo);
					break;
				}
				case CLZNoticeName.OUT_PLAYER:
				{
					this._systemTip.hideOutPlayerTip();
					break;
				}
				case CLZNoticeName.BTN_PLAYER_OPERATE:
				{
					body=notification.getBody();
					curPlayerVo=this._inRoomData.getSitPlayerBySeatId(body.seatId) as PlayerVo;
					if (this._playerPanelMc == null)
					{
						this._playerPanelMc=GameData.getSprite("SitPlayerPanel");
						this.playerPanel=new SitPlayerPanel(this._playerPanelMc);
					}
					this.playerPanel.player=curPlayerVo;
					Texas.I._mcTipView.addChild(this._playerPanelMc);
					showPoint=body.point;
					this._playerPanelMc.x=showPoint.x;
					this._playerPanelMc.y=showPoint.y;
					break;
				}
				case CLZNoticeName.CLOSE_BTN_PLAYER_OPERATE:
				{
					if (this._playerPanelMc != null)
					{
					}
					if (Texas.I._mcTipView.contains(this._playerPanelMc))
					{
						Texas.I._mcTipView.removeChild(this._playerPanelMc);
					}
					break;
				}
				case CLZNoticeName.STAND_UP_RSP:
				{
					if (this.playerPanel != null)
					{
					}
					if (body.seatId == this.playerPanel.player.seatId)
					{
						this.sendNotification(CLZNoticeName.CLOSE_BTN_PLAYER_OPERATE);
					}
					break;
				}
				case CLZNoticeName.SHOW_USE_SELECTED_TIP:
				{
					this._systemTip.showUseTip(body);
					break;
				}
				case CLZNoticeName.HIDE_USE_SELECTED_TIP:
				{
					this._systemTip.removeUseTip();
					break;
				}
				case CLZNoticeName.USE_PROP_TYPE:
				{
					this.sendNotification(CLZNoticeName.USE_PROP_REQ, body);
					break;
				}
				case CLZNoticeName.BUYIN_PROP_TIP_WINDOW:
				{
					this._systemTip.showPropTipPanel(CLZNoticeName.BUYIN_PROP_TIP_WINDOW, body as PropVo);
					break;
				}
				case CLZNoticeName.SEND_PROP_TIP_WINDOW:
				{
					this._systemTip.showPropTipPanel(CLZNoticeName.SEND_PROP_TIP_WINDOW, body as PropVo);
					break;
				}
				case CLZNoticeName.CLOSE_PROP_TIP_WINDOW:
				{
					this._systemTip.removePropTip();
					break;
				}
				case CLZNoticeName.HIDE_SHOPING:
				{
					this.sendNotification(CLZNoticeName.CLOSE_PROP_TIP_WINDOW);
					break;
				}
				case CLZNoticeName.OK_GIVE_BUY_PROP_GIFT:
				{
					if (body.arrMid.length != 1)
					{
						return;
					}
					this.sendNotification(CLZNoticeName.GIVE_GIFT_REQ, body);
					break;
				}
				case CLZNoticeName.SHOW_HONOR_TIP:
				{
					GameData.arrHonorTip.push(body);
					this._systemTip.showHonorTip();
					break;
				}
				case CLZNoticeName.HIDE_HONOR_TIP:
				{
					this._systemTip.hideHonorTip();
					break;
				}
				case CLZNoticeName.INIT_CARD_RANK_TIP:
				{
					if (this._cardRankTip != null)
					{
						return;
					}
					this._cardRankTip=new CardTypeTipPanel(GameData.getSprite("CardTypeTipPanel"));
					break;
				}
				case CLZNoticeName.SHOW_CARD_RANK_TIP:
				{
					this._cardRankTip.show();
					break;
				}
				case CLZNoticeName.HIDE_CARD_RANK_TIP:
				{
					this._cardRankTip.hide();
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		}*/

		private function removeSystemTip(mcTip:Sprite):void
		{
			if (Texas.I._mcTipView.contains(mcTip))
			{
				Texas.I._mcTipView.removeChild(mcTip);
				mcTip=null;
			}
			return;
		}

	}
}
